// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_c;

import android.content.*;
import android.database.Cursor;
import android.text.TextUtils;
import com.nnee.p_b.p_a.cls_d;
import com.nnee.p_pr.p_prot.cls_c;
import com.nnee.p_pr.p_prov.q;

public class cls_h
{

    public cls_h()
    {
    }

    public static long a(Context context, String s)
    {
        long l = 0L;
        if(context != null && s != null)
        {
            ContentResolver contentresolver = context.getContentResolver();
            android.net.Uri uri = q.j;
            String as[] = new String[1];
            as[0] = "refresh";
            String as1[] = new String[1];
            as1[0] = s;
            Cursor cursor = contentresolver.query(uri, as, "name =?", as1, null);
            if(cursor != null)
            {
                long l1;
                if(cursor.moveToFirst())
                    l1 = cursor.getLong(0);
                else
                    l1 = l;
                cursor.close();
                l = l1;
            }
        }
        return l;
    }

    public static Cursor a(Context context)
    {
        String s = null;
        if(context != null)
        {
            String s1 = (new StringBuilder()).append("main = ").append(q.o).toString();
            s = context.getContentResolver().query(q.j, a, s1, s, s);
        }
        return s;
    }

    public static void a(Context context, String s, long l)
    {
        if(context != null && s != null)
            if(c.b.equals(s))
            {
                a(context, c.b, c.b, l);
            } else
            {
                ContentValues contentvalues = new ContentValues();
                contentvalues.put("refresh", Long.valueOf(l));
                ContentResolver contentresolver = context.getContentResolver();
                android.net.Uri uri = q.j;
                String as[] = new String[1];
                as[0] = s;
                contentresolver.update(uri, contentvalues, "name =?", as);
            }
    }

    public static void a(Context context, String s, boolean flag)
    {
        if(!TextUtils.isEmpty(s) && context != null)
        {
            String s1 = (new StringBuilder()).append("name = '").append(s).append("' ").toString();
            ContentValues contentvalues = new ContentValues();
            int j;
            if(flag)
                j = 0;
            else
                j = 1;
            contentvalues.put("first_login", Integer.valueOf(j));
            context.getContentResolver().update(q.j, contentvalues, s1, null);
        }
    }

    public static boolean a(Context context, String s, String s1)
    {
        return a(context, s, s1, 0L);
    }

    public static boolean a(Context context, String s, String s1, long l)
    {
        boolean flag = true;
        if(!TextUtils.isEmpty(s) && !TextUtils.isEmpty(s1)) goto _L2; else goto _L1
_L1:
        flag = false;
_L4:
        return flag;
_L2:
        android.net.Uri uri1;
        if(f(context, s))
        {
            ContentValues contentvalues = new ContentValues();
            contentvalues.put("name", s);
            contentvalues.put("password", s1);
            if(l > 0L)
                contentvalues.put("refresh", Long.valueOf(l));
            ContentResolver contentresolver = context.getContentResolver();
            android.net.Uri uri = q.j;
            String as[] = new String[flag];
            as[0] = s;
            if(contentresolver.update(uri, contentvalues, "name =?", as) <= 0)
                flag = false;
            continue; /* Loop/switch isn't completed */
        }
        ContentValues contentvalues1 = new ContentValues();
        contentvalues1.put("name", s);
        contentvalues1.put("password", s1);
        if(l > 0L)
            contentvalues1.put("refresh", Long.valueOf(l));
        uri1 = context.getContentResolver().insert(q.j, contentvalues1);
        if(uri1 == null)
            break MISSING_BLOCK_LABEL_199;
        long l1 = ContentUris.parseId(uri1);
        if(l1 >= 0L)
            continue; /* Loop/switch isn't completed */
        flag = false;
        continue; /* Loop/switch isn't completed */
        Exception exception;
        exception;
        exception.printStackTrace();
        flag = false;
        if(true) goto _L4; else goto _L3
_L3:
    }

    public static void b(Context context)
    {
        if(context != null)
            context.getContentResolver().delete(q.j, null, null);
    }

    public static void b(Context context, String s)
    {
        if(!TextUtils.isEmpty(s) && context != null)
        {
            String s1 = (new StringBuilder()).append("main = ").append(q.o).toString();
            ContentValues contentvalues = new ContentValues();
            contentvalues.put("main", Integer.valueOf(q.p));
            context.getContentResolver().update(q.j, contentvalues, s1, null);
            String s2 = (new StringBuilder()).append("name = '").append(s).append("'").toString();
            ContentValues contentvalues1 = new ContentValues();
            contentvalues1.put("main", Integer.valueOf(q.o));
            context.getContentResolver().update(q.j, contentvalues1, s2, null);
        }
    }

    public static void b(Context context, String s, long l)
    {
        ContentValues contentvalues = new ContentValues();
        contentvalues.put("other", String.valueOf(l));
        ContentResolver contentresolver = context.getContentResolver();
        android.net.Uri uri = q.j;
        String as[] = new String[1];
        as[0] = s;
        contentresolver.update(uri, contentvalues, "name = ?", as);
    }

    public static boolean b(Context context, String s, String s1)
    {
        if(!com.nnee.p_b.p_a.cls_d.h().i()) goto _L2; else goto _L1
_L1:
        boolean flag = true;
_L4:
        return flag;
_L2:
        Cursor cursor;
        if(s1 == null)
            break MISSING_BLOCK_LABEL_119;
        ContentResolver contentresolver = context.getContentResolver();
        android.net.Uri uri = q.j;
        String as[] = a;
        String as1[] = new String[1];
        as1[0] = s;
        cursor = contentresolver.query(uri, as, "name =?", as1, null);
        if(cursor == null)
            break MISSING_BLOCK_LABEL_107;
        boolean flag1;
        if(!cursor.moveToFirst())
            break MISSING_BLOCK_LABEL_107;
        flag1 = s1.equals(cursor.getString(2));
        flag = flag1;
        if(cursor != null)
            cursor.close();
        continue; /* Loop/switch isn't completed */
        if(cursor != null)
            cursor.close();
        flag = false;
        if(true) goto _L4; else goto _L3
_L3:
        Exception exception;
        exception;
        if(cursor != null)
            cursor.close();
        throw exception;
    }

    public static void c(Context context, String s)
    {
        if(!TextUtils.isEmpty(s) && context != null)
        {
            String s1 = (new StringBuilder()).append("name = '").append(s).append("'").toString();
            context.getContentResolver().delete(q.j, s1, null);
        }
    }

    public static void d(Context context, String s)
    {
        if(!TextUtils.isEmpty(s) && context != null)
        {
            String s1 = (new StringBuilder()).append("name = '").append(s).append("' ").append(" AND ").append("main").append(" = ").append(q.o).toString();
            ContentValues contentvalues = new ContentValues();
            contentvalues.put("main", Integer.valueOf(q.p));
            context.getContentResolver().update(q.j, contentvalues, s1, null);
        }
    }

    public static boolean e(Context context, String s)
    {
        boolean flag = false;
        if(!TextUtils.isEmpty(s) && context != null) goto _L2; else goto _L1
_L1:
        return flag;
_L2:
        String s1 = (new StringBuilder()).append("name = '").append(s).append("' ").toString();
        Cursor cursor = context.getContentResolver().query(q.j, a, s1, null, null);
        if(cursor == null || !cursor.moveToFirst())
        {
            if(cursor != null)
                cursor.close();
        } else
        {
            int j = cursor.getInt(7);
            cursor.close();
            boolean flag1;
            if(j == 0)
                flag1 = true;
            else
                flag1 = flag;
            flag = flag1;
        }
        if(true) goto _L1; else goto _L3
_L3:
    }

    public static boolean f(Context context, String s)
    {
        if(context != null && !TextUtils.isEmpty(s)) goto _L2; else goto _L1
_L1:
        boolean flag = false;
_L4:
        return flag;
_L2:
        ContentResolver contentresolver = context.getContentResolver();
        android.net.Uri uri = q.j;
        String as[] = a;
        String as1[] = new String[1];
        as1[0] = s;
        Cursor cursor = contentresolver.query(uri, as, "name =?", as1, null);
        if(cursor != null)
        {
            if(cursor.moveToFirst())
            {
                cursor.close();
                flag = true;
                continue; /* Loop/switch isn't completed */
            }
            cursor.close();
        }
        flag = false;
        if(true) goto _L4; else goto _L3
_L3:
    }

    public static long g(Context context, String s)
    {
        if(context == null) goto _L2; else goto _L1
_L1:
        Cursor cursor;
        ContentResolver contentresolver = context.getContentResolver();
        android.net.Uri uri = q.j;
        String as[] = a;
        String as1[] = new String[1];
        as1[0] = s;
        cursor = contentresolver.query(uri, as, "name =?", as1, null);
        if(cursor == null) goto _L2; else goto _L3
_L3:
        if(!cursor.moveToFirst()) goto _L5; else goto _L4
_L4:
        String s1 = cursor.getString(6);
        if(s1 == null) goto _L5; else goto _L6
_L6:
        long l1 = Long.parseLong(s1);
        long l;
        l = l1;
        cursor.close();
_L8:
        return l;
_L5:
        cursor.close();
_L2:
        l = 0L;
        if(true) goto _L8; else goto _L7
_L7:
        Exception exception1;
        exception1;
        exception1.printStackTrace();
        cursor.close();
          goto _L2
        Exception exception;
        exception;
        cursor.close();
        throw exception;
    }

    static String a[];
    public static final int b = 0;
    public static final int c = 1;
    public static final int d = 2;
    public static final int e = 3;
    public static final int f = 4;
    public static final int g = 5;
    public static final int h = 6;
    public static final int i = 7;

    static 
    {
        String as[] = new String[8];
        as[0] = "_id";
        as[1] = "name";
        as[2] = "password";
        as[3] = "last_login";
        as[4] = "auot_login";
        as[5] = "main";
        as[6] = "other";
        as[7] = "first_login";
        a = as;
    }
}
